package com.xhy.tool.exception;

import com.xhy.tool.utils.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Author: Xhy
 * CreateTime: 2022-06-04 21:24
 * 全局异常捕获类
 */
@RestControllerAdvice(basePackages = "com.xhy.tool")
public class ExceptionControllerAdvice {

    // 捕获全局异常
    @ExceptionHandler(com.xhy.tool.exception.AuthorityException.class)
    public R exceptionAll(AuthorityException e){
        e.printStackTrace();
        return R.error().message(e.getMsg()).code(e.getCode());
    }
}
